package com.project.service.imp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.project.bean.NewBean;
import com.project.bean.UserBean;
import com.project.mapper.INewMapper;
import com.project.mapper.IUserMapper;
import com.project.service.INewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class NewServiceImp implements INewService {
    @Autowired
    private INewMapper mapper;

    @Override
    public List<NewBean> findByTitleLike(String title) {
        QueryWrapper<NewBean> wrapper = new QueryWrapper<>();
        wrapper.like("n_title", title);
        return mapper.selectList(wrapper);
    }

    @Override
    public void add(NewBean newBean) {
        mapper.insert(newBean);
    }

    @Override
    public void upd(Integer id, Integer status) {
        NewBean newBean = mapper.selectById(id);
        newBean.setStatus(status);
        mapper.updateById(newBean);
    }

    @Override
    public List<NewBean> newSort() {
        return mapper.newSort();
    }

    @Override
    public NewBean findById(Integer newId) {
        return mapper.findById(newId);
    }

}
